/**
  (c) Copyright Gavin Bong 2008

  This work ‘as-is’ we provide.
  No warranty express or implied.
  We’ve done our best,
  to debug and test.
  Liability for damages denied.

  Permission is granted hereby,
  to copy, share, and modify.
  Use as is fit,
  free or for profit.
  These rights, on this notice, rely.
  
  http://genaud.net/2005/10/poetic-license/
 */

package net.boingboing;

public class Bookmark 
{
    private String _description;
    private StringBuilder _tags;
    private long _id;
    private int _path;
    
    private static final String SPACE = " ";
    
    public void init()
    {
        _description = "";
        _tags = new StringBuilder();
        _id = System.currentTimeMillis();
        _path = 0;
    }
    
    public String getUrl()
    {
        return "http://corynotes4j.org/" + _id + "/" + _path;
    }
    
    public String getShortText()
    {
        if( _description == null )
            return "foo";
        
        if( _description.length() <= 60 )
            return _description;
        
        return _description.substring( 0, 59 );
    }
    
    public String getExtended()
    {
        return _description;
    }
    
    public void addDescription( String description )
    {
        _description = description;
    }
    
    public void addTag( String tag )
    {
        if( tag.startsWith("@") )
            tag = tag.substring( 1, tag.length() );
        _tags.append( tag );
        _tags.append( SPACE );
    }
    
    public void addPath( int path )
    {
        _path = path;
    }
    
    public String getSpaceDelimitedTags()
    {
        if( _tags == null || _tags.length() == 0 )
            return null;
        
        return _tags.toString();
    }
}
